package STUDENT.DAODUCGIANG.BASIC.MY_FIRST_JAVA_PROGRAM;

import java.util.Scanner;

public class P2_2 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String Value;
		double a = 0;
		double b = 0;
		int Pheptinh = 0;
		do {
			System.out.println("Moi ban nhap gia tri a");
			Value = sc.nextLine();
			if (Value .isEmpty())
				System.out.println("Gia tri a bat buoc phai nhap");
			else 
				a = Double.parseDouble(Value);		
			} 
		while (Value .isEmpty());
		
		do {
			System.out.println("Moi ban nhap gia tri b");
			Value = sc.nextLine();
			if (Value .isEmpty())
				System.out.println("Gia tri b bat buoc phai nhap");
			else 
				b = Double.parseDouble(Value);		
			} 
		while (Value .isEmpty());
		
		System.out.println("Moi ban chon phep tinh: ");
		Pheptinh = sc.nextInt();
		
		if (Pheptinh == 0)
			System.out.println("Tong 2 so a va b la: "+ (a + b));
		else if (Pheptinh == 1)
			System.out.println("Hieu 2 so a va b la: "+ (a - b));
		else if (Pheptinh == 2)
			System.out.println("Tich 2 so a va b la: "+ (a * b));
		else if (Pheptinh == 3)
			if (a == 0 && b ==0)
				System.out.println("Result of function is underfined");
			else if (a != 0 && b ==0)
				System.out.println("Cannot divide by zero");
			else 
				System.out.println("Thuong 2 so a va b la: "+ (a / b));
		}
	}
